;;首先这句话设置一个目录，你的auto-insert 的模版文件会存放在这个目录中，
(setq-default auto-insert-directory "~/.emacs.d/auto-insert-cache/")

(auto-insert-mode)  ;;; 启用auto-insert

;;If you don't want to be prompted before insertion
(setq auto-insert-query nil) 


;;#(define-auto-insert "\\.org" "org-auto-insert")
;;(define-auto-insert "\\.c" "c-auto-insert")

;;load auto insert define
;;(require 'yasnippet-auto-insert-template)
(load-file "~/.emacs.d/auto-insert-list.el")
(require 'auto-insert-list)


(defadvice auto-insert  (around yasnippet-expand-after-auto-insert activate)
  "expand auto-inserted content as yasnippet templete,
  so that we could use yasnippet in autoinsert mode"
  (let ((is-new-file (and (not buffer-read-only)
                          (or (eq this-command 'auto-insert)
                              (and auto-insert (bobp) (eobp))))))
    ad-do-it
    (let ( (old-point-max (point-max)) (pos (- (point-max) 1)))
      (when is-new-file
        (goto-char pos)
		(yas/expand)))))
;;
(provide 'mod-auto-insert)
